package com.ddy.test.creditcardmanage.model

import androidx.annotation.Nullable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.ddy.test.creditcardmanage.common.Constant
import java.util.Calendar

@Entity(tableName = Constant.TABLE_NAME_CARD)
class Card(
    @PrimaryKey
    @ColumnInfo(name = "id") var id: Long,
    @ColumnInfo(name = "cardNo") var cardNo: String,

    @Nullable
    @ColumnInfo(name = "comment") var comment: String,
    @Nullable
    @ColumnInfo(name = "permanentLine") var permanentLine: Float,
    @Nullable
    @ColumnInfo(name = "temporaryLine") var temporaryLine: Float,
    @Nullable
    @ColumnInfo(name = "statementAmount") var statementAmount: Float,
    @Nullable
    @ColumnInfo(name = "statementDate") var statementDate: Int,
    @Nullable
    @ColumnInfo(name = "dueDate") var dueDate: Int) {



    companion object {
        fun newCard(
            cardNo: String,
            comment: String,
            permanentLine: Float,
            temporaryLine: Float,
            statementAmount: Float,
            statementDate: Int,
            dueDate: Int
        ): Card {
            val id = Calendar.getInstance().timeInMillis
            return Card(id, cardNo, comment, permanentLine, temporaryLine, statementAmount, statementDate, dueDate)
        }
    }

    override fun toString(): String {
        return "card{" +
                ", id=" + id +
                ", cardNo=" + cardNo +
                ", comment=" + comment +
                ", permanentLine=" + permanentLine +
                ", temporaryLine=" + temporaryLine +
                ", statementAmount=" + statementAmount +
                ", statementDate=" + statementDate +
                ", dueDate=" + dueDate
    }



}
